/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#ifndef __QS_TimelineItem_H__
#define __QS_TimelineItem_H__

#include "Prerequisites.h"


#include "Transaction.h"

#include <QtGui/QGraphicsItem>

namespace QSThink
{
	class DiagramView;
	class DiagramEdge;

	class TransactionPos
	{
	public:
		TransactionPos(float position,Transaction* transaction){
			pos=position;
			trans=transaction;
		}
		float pos;
		Transaction* trans;
	};
	class TimelineItem
		: public QGraphicsItem
	{
	public:
		TimelineItem(DiagramView* view);

		~TimelineItem();

		enum { Type = UserType + 4 };
		int type() const { return Type; }


		void addTrans( float x, Transaction* t );
	protected:
		//QRectF QGraphicsItem::boundingRect () const   [pure virtual]
		QRectF boundingRect() const;
		
		//QPainterPath QGraphicsItem::shape () const   [virtual]
		QPainterPath shape() const;

		//void QGraphicsItem::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 )   [pure virtual]
		void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

	protected:
		//QVariant QGraphicsItem::itemChange ( GraphicsItemChange change, const QVariant & value )   [virtual protected]
		QVariant itemChange(GraphicsItemChange change, const QVariant &value);

		void mousePressEvent(QGraphicsSceneMouseEvent *event);
		void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
	protected:
		DiagramView* _view;
		std::vector<TransactionPos> _positions;

		int _startYear;//


		std::map<int,TransactionPos> _trans;
		
	};
}
#endif
